package C6_8_ReplaceMethodWithMethodObject;

/**
 * 以函数对象取代函数
 */
public class Account {
    /**
     * 改造前
     */
    int gamma(int inpuntValue, int quantity, int yearToDate) {
        int importantValue1 = (inpuntValue * quantity) + delta();
        int importantValue2 = (inpuntValue * yearToDate) + 100;
        if ((yearToDate - importantValue1) > 100) {
            importantValue2 -= 20;
        }
        int importantValue3 = importantValue2 * 7;
        // and so on
        return importantValue3 - 2 * importantValue1;
    }

    /**
     * 改造后
     */
    int gamma1(int inpuntValue, int quantity, int yearToDate) {
        return new Gamma(this, inpuntValue, quantity, yearToDate).compute();
    }

    public int delta() {
        return 0;
    }

}
